//
//  MQRegisterViewController.m
//  meiquan
//
//  Created by hejingjin on 2017/10/23.
//  Copyright © 2017年 mq. All rights reserved.
//

#import "MQRegisterViewController.h"
#import "MQMessageCodeViewController.h"
#import "MQRegeisterviewss.h"
#import "NSString+Extension.h"
#import "MBProgressHUD+MJ.h"

@interface MQRegisterViewController ()


@property(nonatomic,strong)MQRegeisterviewss *registerviewss;

@end

@implementation MQRegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"注册";
    
    [self setupmainInterface];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(void)setupmainInterface{
    self.view.backgroundColor = BSTColorFromRGB(0xefefef);
    
    
    _registerviewss = [MQRegeisterviewss loadRegisterviewss];
    _registerviewss.bst_x = 0;
    _registerviewss.bst_y = 64;
    _registerviewss.bst_width = BSTScreenW;
    _registerviewss.bst_height = BSTScreenH - 64;
    _registerviewss.nextsetpnutton.layer.cornerRadius = 4.f;
    _registerviewss.nextsetpnutton.layer.masksToBounds = YES;
    [_registerviewss.nextsetpnutton addTarget:self action:@selector(nextsetpnuttonPressed:)  forControlEvents:UIControlEventTouchUpInside];
    
    
    [self.view addSubview:_registerviewss];
}


-(void)nextsetpnuttonPressed:(UIButton *)sender{
    
    
    NSString *phonestr = _registerviewss.phoneNumberTextfeild.text;
    if ([NSString isBlankString:phonestr]) {
        
        [iToastUtil displayMsg:@"请输入手机号"];
        return;
    }

    if (![phonestr isPhoneNumber]) {
        [iToastUtil displayMsg:@"请输入正确的手机号"];
        return;
    }
    
    [MBProgressHUD showMessage:@"请稍后..."];
    
    if (phonestr.length == 11) {
        [MBProgressHUD hideHUD];
        MQMessageCodeViewController *messagecodevc =[[MQMessageCodeViewController alloc] init];
        messagecodevc.phonestr = phonestr;
        [_registerviewss.phoneNumberTextfeild endEditing:YES];
        [self.view endEditing:YES];
        [self.navigationController pushViewController:messagecodevc animated:YES];
    }else{
        [MBProgressHUD hideHUD];
          [iToastUtil displayMsgBytime:@"请输入正确的手机号" duration:600];
    }
 
}

@end
